<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="css/index2.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<form action="update" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="${param.id}">
	<table>
		<tr>
			<td>商品名称</td><td><input type="text" name="name" id="name"> </td>
		</tr>
		<tr>
			<td>英文名称</td><td><input type="text" name="ename" id="ename"> </td>
		</tr>
		<tr>
			<td>商品品牌</td><td><select id="se1" name="pid">
				<option value="">==请选择品牌==</option>
			</select> </td>
		</tr>
		<tr>
			<td>商品种类</td><td><select id="se2" name="tid">
				<option value="">==请选择种类==</option>
			</select> </td>
		</tr>
		<tr>
			<td>尺寸</td><td><input type="text" name="size" id="size"> </td>
		</tr>
		<tr>
			<td>价格</td><td><input type="text" name="price" id="price"> </td>
		</tr>
		<tr>
			<td>数量</td><td><input type="text" name="number" id="number"> </td>
		</tr>
		<tr>
			<td>标签</td><td><input type="text" name="label" id="label"> </td>
		</tr>
		<tr>
			<td>图片</td><td>
				<img width="100px" >
				<input type="file" name="myFile">
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="submit" value="添加">
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">
$.ajax({
	type:"post",
	url:"selectvariety",
	async:false,
	data:{},
	success:function(mas){
		var ss="";
		for ( var i in mas) {
			ss+="<option value='"+mas[i].tid+"' class='aa'>"+mas[i].tname+"</option>";
		}
		$("#se2").append(ss);
	},
	dataType:"json"
})

$.ajax({
	type:"post",
	url:"selectbrand",
	async:false,
	data:{},
	success:function(mas){
		var ss="";
		for ( var i in mas) {
			ss+="<option value='"+mas[i].pid+"' class='bb'>"+mas[i].pname+"</option>";
		}
		$("#se1").append(ss);
	},
	dataType:"json"
})
var id=${param.id}
$.ajax({
	type:"post",
	url:"updategood1",
	data:{id:id},
	success:function(mas){
		$("#name").val(mas.name);
		$("#ename").val(mas.ename);
		$(".aa[value="+mas.tid+"]").attr("selected",true);
		$(".bb[value="+mas.pid+"]").attr("selected",true);
		$("#size").val(mas.size);
		$("#price").val(mas.price);
		$("#number").val(mas.number);
		$("#label").val(mas.label);
		$("img").attr("src","<%=request.getContextPath() %>/img/"+mas.tu+"");
	}
})


	var zz="${ss}";
	if(zz!=null && zz!=''){
		if(zz){
			alert("修改成功");
			location="cheng";
		}else{
			alert("修改失败");
		} 
	}
	





</script>

</body>
</html>